<template>
  <div>
      <table>
          <tr>
              <td>
                <el-checkbox-group v-model="roleid" v-for="i in rolelist" :key="i.id">
                <el-checkbox :label="i.id">{{i.rname}}</el-checkbox>
                
                </el-checkbox-group>
              </td>
              
                <td>
                    <el-checkbox-group v-model="checkList" v-for="i in resourcelist" :key="i.id">
                <el-checkbox :label="i.id">{{i.name}}</el-checkbox>
                
                </el-checkbox-group>
              <el-button @click="add">用户配置角色</el-button>
                </td>
          
          </tr>
      </table>
        {{this.roleid}}
        {{this.checkList}}
  </div>
</template>

<script>
import axios from 'axios'
export default {
    name:'roleres',
    data(){
        return{
            resourcelist:[],
            checkList:[],
            rolelist:[],
            roleid:[]
        }
    },
    methods:{
      getresourcelist(){
        axios.get('/resourcelist').then(res=>{
          this.resourcelist = res.data.list
        })
      },
      add(){
        axios.post('/role_res',{'role_id':this.roleid[0],'reslist':this.checkList}).then(res=>{
          console.log(res.data);
        })
      },
      getrole(){
          axios.get('/rolelist').then(res=>{
          this.rolelist = res.data.list
        })
      }
    },
    mounted(){
      this.getresourcelist()
    },
    created(){
        this.getrole()
    }
}
</script>

<style>

</style>